<h1>Schools Management</h1>
<div class="subHeader">
	<b>Shools List</b>
	<span>
		<a <?php echo isset($_GET['recent']) ? "class='current'" : NULL;?> href="?recent" >Most Recent</a> | 
		<a <?php echo isset($_GET['popular']) ? "class='current'" : NULL;?> href="?popular" >Most Popular</a>
	</span>
</div>

<?php
	$list = $mvc->getObject('list');
	if(!isset($list) || count($list) == 0){
?>
<span class="message warning">No schools available at this moment.</span>
<?php } else { ?>


<?php foreach($list as $key => $value){ ?>

<div class="pgItemsList">
	<div class="pgListItem wide">
		<h2>
			<a href=<?php echo 'school-details.html?id=' . $value[SchoolService::ID];?>>
				<?php echo isset($value[SchoolService::CAPTION]) ? $value[SchoolService::CAPTION] : null;?>
			</a>
		</h2>
		<div class="pgItemImg">
				<img src="<?php echo isset($value[SchoolService::AVATAR]) ? $value[SchoolService::AVATAR] : null;?>" alt="" title="" />
		</div>
		<div class="pgItemBody">
	    	<ul>
	       		<li><span>Rating:</span>
					<span class="lsValue">
					<?php if(isset($value[SchoolService::RATE])){ if($value[SchoolService::RATE] >= 1){ ?>
					<a href="#"><img src="images/star.png" /></a> <?php }else{ ?> <a href=""><img src="images/gray-star.png" /></a><?php } } ?>
					<?php if(isset($value[SchoolService::RATE])){ if($value[SchoolService::RATE] >= 2){ ?>
					<a href=""><img src="images/star.png" /></a> <?php }else{ ?> <a href=""><img src="images/gray-star.png" /></a><?php } } ?>
					<?php if(isset($value[SchoolService::RATE])){ if($value[SchoolService::RATE] >= 3){ ?>
					<a href=""><img src="images/star.png" /></a> <?php }else{ ?> <a href=""><img src="images/gray-star.png" /></a><?php } } ?>
					<?php if(isset($value[SchoolService::RATE])){ if($value[SchoolService::RATE] >= 4){ ?>
					<a href=""><img src="images/star.png" /></a> <?php }else{ ?> <a href=""><img src="images/gray-star.png" /></a><?php } } ?>
					<?php if(isset($value[SchoolService::RATE])){ if($value[SchoolService::RATE] >= 5){ ?>
					<a href=""><img src="images/star.png" /></a> <?php }else{ ?> <a href=""><img src="images/gray-star.png" /></a><?php } } ?>
					</span>
				</li>
				<li><span>Created:</span><span class="lsValue"><?php echo isset($value[SchoolService::CRDATE]) ? $value[SchoolService::CRDATE] : null;?></span></li>
				<li><span>Categories:</span>
					<span class="lsValue">
					<?php foreach($value['subject'] as $key_sub => $subject){ ?>
						<?php echo $subject[CategoriesService::NAME]; ?>
					<? } ?>
					</span>
				</li>
			</ul>
			<p class="extLink"><?php echo isset($value[SchoolService::DESCRIPTION]) ? $value[SchoolService::DESCRIPTION] : null;?></p>
			<p class="btns">
				<a class="button" href=<?php echo 'edit-school.html?id=' . $value[SchoolService::ID];?>>Edit</a>
				<?php if (isset($value[SchoolService::ENABLED])) { if($value[SchoolService::ENABLED] == '1') { ?>
					<a class="button" href=<?php echo 'index.html?disable=' . $value[SchoolService::ID];?>>Activate</a>
				<?php }else{ ?>
					<a class="button" href="<?php echo 'index.html?enabled=' . $value[SchoolService::ID];?>">Suspend</a> 
				<?php } } ?>
				<a class="button" onclick="return confirm('You sure you want to delete?');" href=<?php echo 'index.html?deleted=' . $value[SchoolService::ID];?>>Delete</a>
			</p>	
		</div>
	</div>
</div>
<?php } } ?>
